# -*- coding: utf-8 -*-
"""
Created on Thu Apr  9 11:26:13 2020

@author: wjx
"""

#错题 12  13  14

#2.8 8 None   9 9 None
#3.1 2 666 3 666 
#4. 1 2 3
#5. 1 168 2 168 3 168
#6.1 168 2 168 666 3
#7.2 999  666 3
#8. 0 2 5 {'range':666,'shilei':438,'lyd':}
#9. 3 19 5 20 5 666 33
#10.3 19 999 20 999 666 33
#11. 2 Userinfo 999 Des 999
#12. 
#13.'alex' 'alex'
#14.True False True False
#15.1 11
#16.'l'
#17.
class Context:
    def __enter__(self):
        self.x = open('a.txt','a')
        return self.x
    
    def do_something(self):
        pass
    
    def __exit__(self,exc_type,exc_val,exc_tb):
        self.x.close()

#with Context() as ctx:
#    ctx.do_something()
#18.
class Stack(object):
    def __init__(self):
        self.data_list = []
        
    def push(self,val):
        self.data_list.append(val)
    
    def pop(self):
        del self.data_list[-1]
       
obj = Stack()
# 调用push方法，将数据加入到data_list中。
obj.push('alex')
obj.push('武沛齐')
obj.push('金老板')

# 调用pop讲数据从data_list获取并删掉，注意顺序(按照后进先出的格式)
v1 = obj.pop() # 金老板
v2 = obj.pop() # 武沛齐
v3 = obj.pop() # alex
#19.'哦' '异常' '哦'

